from meiduo_mall.libs.yuntongxun.sms import CCP
from celery_tasks.main import app


# 添加装饰器
# bind保证task对象作为一个参数传入
# name异步任务别名
# retry_backoff是失败后多久重试
# max_retries 异常自动重试的上限)
@app.task(bind=True, name='send_sms', retry_backoff=3)
def send_sms(self, to, datas, tempid):
    try:

        # ccp = CCP()
        # ret = ccp_send_template_sms(to,datas,1)
        # 打印验证码
        print(datas[0])
    # except:
    #     self.retry(max_retries=3)
    except Exception as e:
        self.retry(exc=e, max_retries=3)
